<!DOCTYPE html>
<html>
<!-- 课件管理-编辑 -->

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="/static/js/common.js"></script>

</head>

<body>
    <div id="app" class="popupW50" v-cloak>
        <el-form label-position="right" :model="Form" status-icon :rules="rules" ref="ruleForm" label-width="100px"
            size="mini">
            <el-row>
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item prop="Topicname">
                            <el-input type="text" v-model="Form.Topicname" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{Coursewaremanagement.Topicname+mark.m}}
                                </template>
                            </el-input>
                            <span class="iputLineMust" v-if="Form.Topicname.length<=0">
                                <!-- 必填项添加 -->
                                <img src="/static/images/exclamation.png" alt="">
                            </span>

                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="11" offset="2">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input size="mini">
                                    <template slot="prepend">
                                        <div> {{Coursewaremanagement.Trainingmode+mark.m}}</div>
                                    </template>
                                    <el-select @visible-change="visibleChange" v-model="Form.Trainingmode" slot="suffix"
                                        :placeholder="Coursewaremanagement.Trainingmode">
                                        <el-option label="请选择" value=""></el-option>
                                        <el-option v-for="item in Trainingmode" :label="item.value" :value="item.key">
                                        </el-option>
                                    </el-select>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>


                <el-col :span="20">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input disabled type="text" v-model="Form.Courseware" autocomplete="off" size="mini" readonly>
                                <template slot="prepend">
                                    {{Coursewaremanagement.Courseware+mark.m}}
                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="4">
                    <el-upload ref="Attachmentupload" action="/api/File/UpdateFile" multiple="true"
                        :on-preview="handlePreview" :on-remove="handleRemove"
                        :before-upload="CoursewareUploadbeforeupload" :auto-upload="true" :limit="1"
                        :show-file-list="false">
                        <el-button class="ml10" type="primary" size="mini" @click="btnAttachmentUpload">
                            {{col.btnImportcourseware}}
                        </el-button>
                    </el-upload>
                </el-col>
                <el-col :span="20">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input disabled type="text" v-model="Form.testquestions" autocomplete="off" size="mini" readonly>
                                <template slot="prepend">
                                    {{Coursewaremanagement.testquestions+mark.m}}
                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="4">
                    <el-upload ref="Attachmentupload" action="/api/File/UpdateFile" multiple="true"
                        :on-preview="handlePreview" :on-remove="handleRemove"
                        :before-upload="testquestionsUploadbeforeupload" :auto-upload="true" :limit="1"
                        :show-file-list="false">
                        <el-button class="ml10" type="primary" size="mini" @click="btnAttachmentUpload">
                            {{col.btnImporttestquestions}}
                        </el-button>
                    </el-upload>
                </el-col>
            </el-row>
            <el-row>
                <el-col class="head-tool" style="margin-top:15px;">
                    考题信息
                    <el-button type="primary" @click="UserInput('tj')" size="mini" style="margin-left:15px;">{{col.btnAdd}}
                    </el-button>

                    <el-button type="danger" size="mini" @click="onDelete">{{col.btnDelete}}</el-button>
                </el-col>
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item prop="Totalscore">
                            <el-input type="text" v-model="Form.Totalscore" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{Coursewaremanagement.Totalscore+mark.m}}
                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="11" offset="2">
                    <div class="elst-select-mini">
                        <el-form-item prop="Qualifiedscore">
                            <el-input type="text" v-model="Form.Qualifiedscore" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{Coursewaremanagement.Qualifiedscore+mark.m}}
                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item prop="Scoreperitem">
                            <el-input type="text" v-model="Form.Scoreperitem" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{Coursewaremanagement.Scoreperitem+mark.m}}
                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-table ref="table" stripe :data="ListItem.tableData" :row-key="getRowKeys" border
                    @selection-change="handleSelectionChange" row-style="height:10px" style="width: 100%;">
                    <el-table-column type="selection" style="
    padding-top: 0px;
    padding-bottom: 0px;
    " algin="center" width="55" :reserve-selection="true">
                    </el-table-column>
                    <el-table-column type="index" :label="col.SequenceNumber" :index="indexMethod" width="50"
                        show-overflow-tooltip="true"></el-table-column>
                    <el-table-column prop="Titleoftitle" :label="Coursewaremanagement.Titleoftitle" width="">
                    </el-table-column>
                    <el-table-column prop="Questiontype" :label="Coursewaremanagement.Questiontype" width="">
                    </el-table-column>
                    <el-table-column prop="Answer" :label="Coursewaremanagement.Answer" width="">
                    </el-table-column>
                    <el-table-column width="53" :label="col.btnUpdate" fixed="right">
                        <template slot-scope="scope">
                            <button type="button" class="elst-bt-xg" @click=UserInput('xg',scope.row.id)>
                                <i class="el-icon-edit"></i>
                            </button>
                        </template>
                    </el-table-column>
                </el-table>
            </el-row>
            <el-row type="flex" justify="end">
                <el-pagination ref="page" @size-change="handleSizeChange" @current-change="handleCurrentChange"
                    :current-page="ListItem.currentPage" :page-sizes="ListItem.pagesizes" :page-size="ListItem.pagesize"
                    :layout="ListItem.layout" :total="ListItem.total">
                </el-pagination>
            </el-row>
            <br>
            <el-row type="flex" justify="end">
                <el-form-item>
                    <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnSave}}</el-button>
                    <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnCommit}}</el-button>
                    <el-button type="primary" @click="parent.ListItem.dialogVisible=false">{{col.btnBack}}</el-button>
                </el-form-item>
            </el-row>
        </el-form>
        <el-dialog title="试题编辑" fullscreen="true" :visible.sync="ListItem.dialogVisible" @close='closeDialog'
            width="80%" height="80%" top="10vh">
            <iframe ref="iframe" :src="ListItem.InputUrl" style="height:95%;width:100%" frameborder="0"></iframe>
        </el-dialog>
    </div>
    <script type="text/javascript">
        var uploadText = "请选择上传文件";
        var app = new Vue({
            el: '#app',
            data: {
                //父业传参
                id: '',
                value1: '',
                ListItem: ListItem,
                Trainingmode: [],
                Trainingobjectives: [],
                formInline: {
                    model: { Topicname: '', Trainingdate: '', Trainingtype: '', Totalscore: '', Qualifiedscore: '', Scoreperitem: '', Trainingobjectives: '', Trainingmode: '' },
                    offset: 0,
                    limit: 10
                },
                //业务表单内容
                Form: {
                    id: guidEmpty,
                    Topicname: '',
                    Trainingdate: '',
                    Trainingtype: '',
                    Totalscore: '',
                    Qualifiedscore: '',
                    Scoreperitem: '',
                    Trainingobjectives: '',
                    Trainingmode: '',
                    Courseware: uploadText,
                    testquestions: uploadText
                },
                //表单验证
                rules: {
                    // Topicname: [
                    //     verification.NotNull
                    // ],
                    // Trainingdate: [
                    //     verification.NotNullSelect
                    // ],
                    // Trainingtype: [
                    //     verification.NotNull
                    // ],
                    // Totalscore: [
                    //     verification.NotNull
                    // ],
                    // Qualifiedscore: [
                    //     verification.NotNull
                    // ],
                    // Scoreperitem: [
                    //     verification.NotNull
                    // ],
                    // Trainingobjectives: [
                    //     verification.NotNull
                    // ],
                    // Trainingmode: [
                    //     verification.NotNull
                    // ]
                }
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                handleRemove: function (file) {
                    console.log(file);
                },
                handlePreview: function (file) {
                    console.log(file.name);
                    window.open(file.url)
                },
                //上传前文件的校验
                testquestionsUploadbeforeupload: function (file) {
                    var testmsg = file.name.substring(file.name.lastIndexOf('.') + 1)
                    //将附件名赋值到label上
                    this.Form.testquestions = file.name;
                    const extension = testmsg === 'doc'
                    const extension2 = testmsg === 'pdf'
                    const isLt10M = file.size / 1024 / 1024 < 10
                    if (!extension && !extension2) {
                        this.$message({
                            message: '上传文件只能是 doc、pdf格式!',
                            type: 'warning'
                        });
                    }
                    if (!isLt10M) {
                        this.$message({
                            message: '上传文件大小不能超过 10MB!',
                            type: 'warning'
                        });
                    }
                    if (extension || extension2 && isLt10M)
                        submitUpload(this, 'upload')
                    return extension || extension2 && isLt10M
                },
                //上传附件文件的校验
                CoursewareUploadbeforeupload: function (file) {
                    var testmsg = file.name.substring(file.name.lastIndexOf('.') + 1)
                    //将附件名赋值到label上
                    this.Form.Courseware = file.name;
                    const extension = testmsg === 'doc'
                    const extension2 = testmsg === 'pdf'
                    const isLt10M = file.size / 1024 / 1024 < 10
                    if (!extension && !extension2) {
                        this.$message({
                            message: '上传文件只能是 doc、pdf格式!',
                            type: 'warning'
                        });
                    }
                    if (!isLt10M) {
                        this.$message({
                            message: '上传文件大小不能超过 10MB!',
                            type: 'warning'
                        });
                    }
                    if (extension || extension2 && isLt10M)
                        submitUpload(this, 'upload')
                    return extension || extension2 && isLt10M
                },
                btnAttachmentUpload: function () {
                    //若更换文件则将文件名字更换触发条件--先删除上一个文件,后添加一个文件
                    if (this.fileAttachmentUpload != uploadText) {
                        this.$refs.Attachmentupload.clearFiles();
                        this.fileAttachmentUpload = file.name;
                    }
                    else {

                    }
                    this.$refs.Attachmentupload.submit();
                },
                indexMethod: function (index) {
                    return (this.ListItem.currentPage - 1) * this.ListItem.pagesize + index + 1;
                },
                //获取分页数据
                GetPageData: function (currentIndex) { GetPageData(this, currentIndex, '/api/Coursewaremanagement/GetList') },
                //查询方法
                onSubmit: function () { onSubmit(this); },
                btnUpLoad: function () {
                    this.$message({
                        message: '上传成功',
                        type: 'success'
                    });
                },
                //提交数据
                onSubmitForm: function (formName) {
                    var mythis = this;
                    this.$refs[formName].validate(function (valid) {
                        //验证通过
                        if (valid) {
                            onSubmitForm(this, '/api/Coursewaremanagement/Save', mythis.Form);
                        } else {
                            //验证失败
                            return false;
                        }
                    });
                },
                getData: function () {
                    getData(this, '/api/Coursewaremanagement/get?id=' + this.id);
                },

                //删除方法
                onDelete: function () { onDelete(this, '/api/Coursewaremanagement/DeleteMuti'); },
                //Dialog展示
                UserInput: function (val, id) { DialogShow(this, val, "CoursewaremanagementInputtQues.html", id); },
                //列表选择触发
                handleSelectionChange: function (val) { handleSelectionChange(this, val); },
                //获取分页数据
                GetPageData: function (currentIndex) { GetPageData(this, currentIndex, '/api/Coursewaremanagement/GetList') },
                //pagesize改变 触发方法
                handleSizeChange: function (val) { handleSizeChange(this, val); },
                //跳页触发方法
                handleCurrentChange: function (val) { handleCurrentChange(this, val); },
            },
            mounted: function () {
                //初始化数据
                this.GetPageData(1);
                //列表高度自适应
                tablehigh(this);
                this.id = getUrlParam("id");
                this.getData();
                //获取下拉菜单内容
                this.Trainingmode = getDicData('w64');
                this.Trainingobjectives = getDicData('17');
            }

        });
    </script>
</body>

</html>